package cn.com.weather.nf.vo;

import java.io.Serializable;
import java.util.List;

/**
 *
 */
public class BeanResult {

    public static final String FLAG_OF_ERROR = "ERROR";
    public static final String FLAG_OF_SUCCESS = "SUCCESS";

    private String status;
    private String cause;
    private Object data;


    public static BeanResult error(String cause) {
        BeanResult bean = new BeanResult();
        bean.status = FLAG_OF_ERROR;
        bean.cause = cause;

        return bean;
    }


    public static BeanResult success(Object data) {
        BeanResult bean = new BeanResult();
        bean.status = FLAG_OF_SUCCESS;
        bean.data = data;

        return bean;
    }


    public static BeanResult success(Integer total, List<Serializable> rows) {
        BeanResult bean = new BeanResult();
        bean.status = FLAG_OF_SUCCESS;
        bean.data = new ListResult(total, rows);

        return bean;
    }


    /**
     * @return
     */
    public String getStatus() {
        return status;
    }

    /**
     * @return
     */
    public String getCause() {
        return cause;
    }

    /**
     * @return
     */
    public Object getData() {
        return data;
    }

    @Override
    public String toString() {
        return super.toString();
    }
}

